package com.foton.smsserver.util;

import java.net.URLClassLoader;

/**
 * @Author RenPu
 * @Date 2024/2/4 18:11
 * @Version 1.0
 * @Description:
 **/
public class ClassLoaderUtil {

    public static Class<?> getClassByPackageName(String packageName) throws ClassNotFoundException {
        String className = packageName.replace('.', '/') + ".Main"; // 假设子包中有一个名为Main的类
        URLClassLoader classLoader = (URLClassLoader)ClassLoader.getSystemClassLoader();
        Class<?> clazz = classLoader.loadClass(className);
        return clazz;
    }
}
